const mysql=require('mysql2/promise'),
log=console.log,
{con}=require('./common.js');

//首页推荐界面
async function essay(){
    const sql = 'select * from user.essay';
    let [rows] = await con.execute(sql);
    return rows;
}
//文章对应的用户信息
async function user(id){
    console.log("zheshi"+id);
    const sql = `select image from user.user where id=${id}`;
    let [rows] = await con.execute(sql);
    return rows;
}
//查找用户名字
async function userName(id){
    console.log("zheshi"+id);
    const sql = `select userName from user.user where id=${id}`;
    let [rows] = await con.execute(sql);
    return rows;
}
//文章的图片
async function essayImage(id){
    const sql = `SELECT img FROM user.essayimage where id=${id} limit 1`;
    let [rows] = await con.execute(sql);
    return rows;
}

async function likeState(userId){
    const sql = `SELECT passageId FROM user.like where userId=${userId}`
    let [rows] = await con.execute(sql);
    return rows;
}

module.exports={essay,user,essayImage,userName,likeState};